﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using LunwenYun.Infrastructure.Entities.Repository;
using LunwenYun.Infrastructure.Entities.Enum;
using LunwenYun.Infrastructure.Entities.Cache;

namespace LunwenYun.Infrastructure.Entities.Entity
{
    /// <summary>
    /// 期刊组织
    /// </summary>
    public class Periodical : IAccessible<T_Periodical, Periodical>, ILogicEntity<T_Periodical, Periodical>
    {
        #region Fileds
        public int Id { get; set; }
        public int Type { get; set; }
        public String Aptitude { get; set; }
        public Language Language { get; set; }
        /// <summary>
        /// 稿件编号规则
        /// </summary>
        public string Manuscriptcode { get; set; }
        /// <summary>
        /// 行业分类
        /// </summary>
        public IndType IndType { get; set; }
        public SubIndType SubIndType { get; set; }
        /// <summary>
        /// 出版社_Id
        /// </summary>
        public int Press_Id { get; set; }
        /// <summary>
        /// 期刊名称
        /// </summary>
        public string Name { get; set; }
        /// <summary>
        /// 期刊英文名
        /// </summary>
        public string Name_EN { get; set; }
        /// <summary>
        /// 期刊缩写
        /// </summary>
        public string ShortName { get; set; }
        /// <summary>
        /// 管理员账户
        /// </summary>
        public string Admin { get; set; }
        /// <summary>
        /// 出版周期
        /// </summary>
        public PubRate PubRate { get; set; }
        /// <summary>
        /// 出版时间
        /// </summary>
        public string PubTime { get; set; }
        /// <summary>
        /// 创刊日期
        /// </summary>
        public DateTime FoundTime { get; set; }
        /// <summary>
        /// 主管单位
        /// </summary>
        public string ZGDW { get; set; }
        /// <summary>
        /// 主管单位_EN
        /// </summary>
        public string ZGDW_EN { get; set; }
        /// <summary>
        /// 主持单位
        /// </summary>
        public string ZCDW { get; set; }
        /// <summary>
        /// 主持单位_EN
        /// </summary>
        public string ZCDW_EN { get; set; }
        /// <summary>
        /// 主办单位
        /// </summary>
        public string ZBDW { get; set; }
        /// <summary>
        /// 主办单位_EN
        /// </summary>
        public string ZBDW_EN { get; set; }
        /// <summary>
        /// 协办单位
        /// </summary>
        public string XBDW { get; set; }
        /// <summary>
        /// 协办单位_EN
        /// </summary>
        public string XBDW_EN { get; set; }
        /// <summary>
        /// 出版单位
        /// </summary>
        public string CBDW { get; set; }
        /// <summary>
        /// 出版单位_EN
        /// </summary>
        public string CBDW_EN { get; set; }
        /// <summary>
        /// 高级顾问
        /// </summary>
        public string GJGW { get; set; }
        /// <summary>
        /// 高级顾问_EN
        /// </summary>
        public string GJGW_EN { get; set; }
        /// <summary>
        /// 编审顾问
        /// </summary>
        public string BSGW { get; set; }
        /// <summary>
        /// 编审顾问_EN
        /// </summary>
        public string BSGW_EN { get; set; }
        /// <summary>
        /// 社长
        /// </summary>
        public string SZ { get; set; }
        /// <summary>
        /// 主任
        /// </summary>
        public string ZR { get; set; }
        /// <summary>
        /// 主编
        /// </summary>
        public string Editor { get; set; }
        /// <summary>
        /// 主编英文名
        /// </summary>
        public string Editer_EN { get; set; }
        /// <summary>
        /// 发行范围
        /// </summary>
        public string Range { get; set; }
        /// <summary>
        /// 期刊详情
        /// </summary>
        public string Detail { get; set; }
        /// <summary>
        /// 国际标准连续出版物号
        /// </summary>
        public string GJBZLXCBWH { get; set; }
        /// <summary>
        /// 国内统一连续出版物号
        /// </summary>
        public string GNTYLXCBWH { get; set; }
        /// <summary>
        /// 邮发代号
        /// </summary>
        public string YFDH { get; set; }
        /// <summary>
        /// 期刊简介
        /// </summary>
        public string Introduction { get; set; }
        /// <summary>
        /// 期刊简介_EN
        /// </summary>
        public string Introduction_EN { get; set; }
        /// <summary>
        /// 征稿启事
        /// </summary>
        public string CallForPaper { get; set; }
        /// <summary>
        /// 征稿启事_EN
        /// </summary>
        public string CallForPaper_EN { get; set; }
        /// <summary>
        /// 注册时间
        /// </summary>
        public DateTime RegTime { get; set; }
        /// <summary>
        /// ISSN Print
        /// </summary>
        public string ISSN_Print { get; set; }
        /// <summary>
        /// ISSN Online
        /// </summary>
        public string ISSN_Online { get; set; }
        /// <summary>
        /// CN刊号
        /// </summary>
        public string CN_Code { get; set; }
        /// <summary>
        /// 期刊邮箱
        /// </summary>
        public string Email { get; set; }
        /// <summary>
        /// 联系电话
        /// </summary>
        public string Phone { get; set; }
        /// <summary>
        /// 检索信息
        /// </summary>
        public string Retrieval { get; set; }        
        /// <summary>
        /// 核心期刊描述
        /// </summary>
        public string HeXinDescription { get; set; }
        public string Honour { get; set; }
        /// <summary>
        /// 期刊封面
        /// </summary>
        public string CoverImg { get; set; }
        public int VisitNumber { get; set; }
        public int DownloadNumber { get; set; }
        /// <summary>
        /// 启用或停用
        /// </summary>
        public bool IsActive { get; set; }
        /// <summary>
        /// 作者须知
        /// </summary>
        public string Attention { get; set; }
        /// <summary>
        /// 稿件模板
        /// </summary>
        public string ManuscriptTemplete { get; set; }
        /// <summary>
        /// 默认审回时间
        /// </summary>
        public int DefaultExamineDay { get; set; }
        /// <summary>
        /// 期刊默认页面数
        /// </summary>
        public int ManuscriptPageSize { get; set; }
        /// <summary>
        /// 是否收取专审费
        /// </summary>
        public bool IsFeeForExpertExmaine { get; set; }
        /// <summary>
        /// 不超过默认页面数价格
        /// </summary>
        public int PagePrice { get; set; }
        /// <summary>
        /// 每超过一页价格
        /// </summary>
        public int PricePerPrice { get; set; }
        /// <summary>
        /// 征稿范围
        /// </summary>
        public string ZGFW { get; set; }
        /// <summary>
        /// 审稿单
        /// </summary>
        public string ExamineSheet { get; set; }
        /// <summary>
        /// 出版费
        /// </summary>
        public int PublicationPrice { get; set; }
        public decimal Price { get; set; }
        /// <summary>
        /// 主页
        /// </summary>
        public string URL { get; set; }
        public string Address { get; set; }
        /// <summary>
        /// 邮编
        /// </summary>
        public string PostCode { get; set; }
        /// <summary>
        /// 邮发代号
        /// </summary>
        public string PostNo { get; set; }
        public bool IsNew { get; set; }
        /// <summary>
        /// 期刊创建者
        /// </summary>
        public string Creator { get; set; }
        #endregion

        public User CreatorUser { get; set; }
        protected override void Covariant(T_Periodical model)
        {
            if (model != null)
            {
                this.Type = model.Type;
                this.Admin = model.Admin;
                this.BSGW = model.BSGW;
                this.BSGW_EN = model.BSGW_EN;
                this.CallForPaper = model.CallForPaper;
                this.CallForPaper_EN = model.CallForPaper_EN;
                this.CBDW = model.CBDW;
                this.CBDW_EN = model.CBDW_EN;
                this.CoverImg = model.CoverImg;
                this.DownloadNumber = model.DownloadNumber;
                this.Editer_EN = model.Editer_EN;
                this.Editor = model.Editor;
                this.Email = model.Email;
                this.FoundTime = model.FoundTime;
                this.GJBZLXCBWH = model.GJBZLXCBWH;
                this.GJGW = model.GJGW;
                this.GJGW_EN = model.GJGW_EN;
                this.GNTYLXCBWH = model.GNTYLXCBWH;
                this.Id = model.Id;
                this.IndType = (IndType)model.IndType;
                this.SubIndType = (SubIndType)model.SubIndType;
                this.Introduction = model.Introduction;
                this.Introduction_EN = model.Introduction_EN;
                this.ISSN_Online = model.ISSN_Online;
                this.ISSN_Print = model.ISSN_Print;
                this.Manuscriptcode = model.Manuscriptcode;
                this.Name = model.Name;
                this.Name_EN = model.Name_EN;
                this.ShortName = model.ShortName;
                this.Press_Id = model.Press_Id;
                this.PubRate = (PubRate)model.PubRate;
                this.PubTime = model.PubTime;
                this.Range = model.Range;
                this.RegTime = model.RegTime;
                this.Retrieval = model.Retrieval;
                this.VisitNumber = model.VisitNumber;
                this.XBDW = model.XBDW;
                this.XBDW_EN = model.XBDW_EN;
                this.YFDH = model.YFDH;
                this.ZBDW = model.ZBDW;
                this.ZBDW_EN = model.ZBDW_EN;
                this.ZCDW = model.ZCDW;
                this.ZCDW_EN = model.ZCDW_EN;
                this.ZGDW = model.ZGDW;
                this.ZGDW_EN = model.ZGDW_EN;
                this.IsActive = model.IsActive;
                this.Attention = model.Attention;
                this.DefaultExamineDay = model.DefaultExamineDay;
                this.ManuscriptTemplete = model.ManuscriptTemplete;
                this.ManuscriptPageSize = model.ManuscriptPageSize;
                this.IsFeeForExpertExmaine = model.IsFeeForExpertExmaine;
                this.PagePrice = model.PagePrice;
                this.PricePerPrice = model.PricePerPrice;
                this.ZGFW = model.ZGFW;
                this.ExamineSheet = model.ExamineSheet;
                this.PublicationPrice = model.PublicationPrice;
                this.Detail = model.Detail;
                this.IsNew = model.IsNew;
                this.Address = model.Address;
                this.Aptitude = model.Aptitude;
                this.CN_Code = model.CN_Code;
                this.Language = (Language)model.Language;
                this.PostCode = model.PostCode;
                this.PostNo = model.PostNo;
                this.Price = model.Price;
                this.SZ = model.SZ;
                this.URL = model.URL;
                this.ZR = model.ZR;
                this.Phone = model.Phone;
                this.HeXinDescription = model.HeXinDescription;
                this.Honour = model.Honour;
                this.Creator = model.Creator;
            }
        }
        protected override T_Periodical Inverter(Periodical model)
        {
            if (model != null)
            {
                return new T_Periodical()
                {
                    Type = (int)model.Type,
                    Admin = model.Admin,
                    BSGW = model.BSGW,
                    BSGW_EN = model.BSGW_EN,
                    CallForPaper = model.CallForPaper,
                    CallForPaper_EN = model.CallForPaper_EN,
                    CBDW = model.CBDW,
                    CBDW_EN = model.CBDW_EN,
                    CoverImg = model.CoverImg,
                    DownloadNumber = model.DownloadNumber,
                    Editer_EN = model.Editer_EN,
                    Editor = model.Editor,
                    Email = model.Email,
                    FoundTime = model.FoundTime,
                    GJBZLXCBWH = model.GJBZLXCBWH,
                    GJGW = model.GJGW,
                    GJGW_EN = model.GJGW_EN,
                    GNTYLXCBWH = model.GNTYLXCBWH,
                    Id = model.Id,
                    IndType = (int)model.IndType,
                    SubIndType = (int)model.SubIndType,
                    Introduction = model.Introduction,
                    Introduction_EN = model.Introduction_EN,
                    ISSN_Online = model.ISSN_Online,
                    ISSN_Print = model.ISSN_Print,
                    Manuscriptcode = model.Manuscriptcode,
                    Name = model.Name,
                    Name_EN = model.Name_EN,
                    ShortName = model.ShortName,
                    Press_Id = model.Press_Id,
                    PubRate = (int)model.PubRate,
                    PubTime = model.PubTime,
                    Range = model.Range,
                    RegTime = model.RegTime,
                    Retrieval = model.Retrieval,
                    VisitNumber = model.VisitNumber,
                    XBDW = model.XBDW,
                    XBDW_EN = model.XBDW_EN,
                    YFDH = model.YFDH,
                    ZBDW = model.ZBDW,
                    ZBDW_EN = model.ZBDW_EN,
                    ZCDW = model.ZCDW,
                    ZCDW_EN = model.ZCDW_EN,
                    ZGDW = model.ZGDW,
                    ZGDW_EN = model.ZGDW_EN,
                    IsActive = model.IsActive,
                    Attention = model.Attention,
                    DefaultExamineDay = model.DefaultExamineDay,
                    ManuscriptTemplete = model.ManuscriptTemplete,
                    ManuscriptPageSize = model.ManuscriptPageSize,
                    IsFeeForExpertExmaine = model.IsFeeForExpertExmaine,
                    PagePrice = model.PagePrice,
                    PricePerPrice = model.PricePerPrice,
                    ZGFW = model.ZGFW,
                    ExamineSheet = model.ExamineSheet,
                    PublicationPrice = model.PublicationPrice,
                    Detail = model.Detail,
                    IsNew = model.IsNew,
                    Address = model.Address,
                    Aptitude = model.Aptitude,
                    CN_Code = model.CN_Code,
                    Language = (int)model.Language,
                    PostCode = model.PostCode,
                    PostNo = model.PostNo,
                    Price = model.Price,
                    SZ = model.SZ,
                    URL = model.URL,
                    ZR = model.ZR,
                    Phone = model.Phone,
                    HeXinDescription = model.HeXinDescription,
                    Honour = model.Honour,
                    Creator = model.Creator
                };
            }
            return null;
        }
        public Periodical Set(T_Periodical dbModel)
        {
            Covariant(dbModel);
            return this;
        }

        /// <summary>
        /// 通过Id查找
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        public override Periodical Find(string key)
        {
            return new PeriodicalCache().GetItem(key);
        }
        public override Periodical PostDelete()
        {
            new PeriodicalCache().RefreshItem(Id.ToString());
            return base.PostDelete();
        }
        public override Periodical PostModify()
        {
            new PeriodicalCache().RefreshItem(Id.ToString());
            return base.PostModify();
        }
        public Periodical LoadCreator(User user)
        {
            this.CreatorUser = user;
            return this;
        }
    }
}
